/*
 * Copyright:  2018 smarabbit studio.
 *
 *  Licensed under the Confluent Community License; you may not use this file
 *  except in compliance with the License.  You may obtain a copy of the License at
 *
 *  http://www.confluent.io/confluent-community-license
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *  WARRANTIES OF ANY KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations under the License.
 *
 *  @作   者： 黄开晖 (117227773@qq.com)
 *  @日   期:  2020年8月29日
 */
package com.massyframework.beanskin.assembly.handling;

import java.util.List;

/**
 * {@link HandlerRegistry}, 支持装配件Handler的注册和注销.
 * @author  Huangkaihui
 *
 */
public interface HandlerRegistry {

	/**
     * 查找任意从<code>handlerType</code>派生的处理器
     *
     * @param handlerType {@link Class}, 处理器类型
     * @param <H>
     * @return {@link H}, 无满足条件的处理器，可以返回null.
     */
    <H> H findHandler(Class<H> handlerType);
    
    /**
     * 获取从指定<code>handlerTpye</code>类型下派生的处理器
     * @param handlerType {@link Class}, 处理器类型
     * @param <H>
     * @return {@link H}, 处理器实例
     * @throws HandlerNotFoundException 如果未找到符合要求的处理器，则抛出例外
     */
    <H> H getHandler(Class<H> handlerType) throws HandlerNotFoundException;

    /**
     * 获取所有从<code>handlerType</code>派生的处理器
     *
     * @param handlerType {@link Class}, 处理器类型
     * @param <H>
     * @return {@link List}
     */
    <H> List<H> getHandlers(Class<H> handlerType);

    /**
     * 注册处理器
     * @param handler {@link T},处理器实例
     * @return {@link HandlerRegistration}
     */
    <T> HandlerRegistration<T> register(T handler) throws Exception;
}
